package com.datang.petstore.controller.web;

import com.datang.petstore.entity.Role;
import com.datang.petstore.resultpage.Result;
import com.datang.petstore.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-11-11 11:20
 * @notify 权限相关api
 * @version 1.0
 */
@RestController
public class WebRoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping("/manage/role")
    public Result getSummaryUserAge() {
        List<Role> roleList = roleService.getRoleList();
        return Result.ok(roleList);
    }

    @PostMapping("/manage/role")
    public Result addRole(@RequestBody Role role) {
        roleService.addRole(role);
        return Result.ok();
    }


    @DeleteMapping("/manage/role")
    public Result deleteRole(@RequestBody Role role) {
        roleService.deleteRole(role);
        return Result.ok();
    }


}
